<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>字典表</title>
    <meta content="" name="keywords"/>
    <meta content="" name="description"/>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../xznstatic/css/common.css" rel="stylesheet"/>
    <link href="../../xznstatic/css/style.css" rel="stylesheet"/>
    <script src="../../xznstatic/js/jquery-1.11.3.min.js" type="text/javascript"></script>
    <script src="../../xznstatic/js/jquery.SuperSlide.2.1.1.js" type="text/javascript"></script>
    <link href="../../xznstatic/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../../css/theme.css" rel="stylesheet"/>
</head>
<style>
    .center-container {
        width: 1200px;
        margin: 0 auto;
        margin-top: 20px;
        display: flex;
        margin-bottom: 20px;
    }

    /*添加地址按钮样式*/
    .btn-container {
        margin-top: 20px;
        text-align: right;
        margin-bottom: 60px;
        border: 2px dotted #EEEEEE;
        padding: 20px;
    }

    /*腰线*/
    .index-title {
        text-align: center;
        box-sizing: border-box;
        width: 980px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }

    .index-title span {
        padding: 0 10px;
        line-height: 1.4;
    }

    /*小菜单样式*/

    .center-container .left-container {
        border: 2px dotted #EEEEEE;
        width: 200px;
        padding-top: 20px;
    }

    .center-container .right-container {
        flex: 1;
        border: 2px dotted #EEEEEE;
        background: #FFFFFF;
        text-align: left;
        padding: 20px;
        padding-top: 40px;
    }

    .center-container .layui-nav-tree {
        margin-top: 20px;
        width: 80%;
    }

    .center-container .layui-nav {
        position: inherit;
    }

    .center-container .layui-nav-tree .layui-nav-item {
        line-height: 44px;
        font-size: 16px;
        color: rgba(17, 17, 17, 1);
        border-width: 0px 0px 1px 0px;
        border-style: solid;
        border-radius: 0;
        background-color: #fff;
        text-align: center;
        border-color: var(--publicMainColor);
        box-shadow: 0 0 0px var(--publicMainColor);
    }

    .center-container .layui-nav-tree .layui-nav-bar {
        height: 44px !important;
        opacity: 0 !important;
    }

    .center-container .layui-nav-tree .layui-nav-item.layui-this {
        font-size: 16px;
        color: rgba(17, 17, 17, 1);
        border-width: 0;
        border-style: solid;
        border-radius: 0;
        background-color: var(--publicSubColor);
    }

    .center-container .layui-nav-tree .layui-nav-item:hover {
        font-size: 14px;
        color: #fff;
        border-width: 0;
        border-style: solid;
        border-radius: 0;
        background-color: var(--publicMainColor);
    }

    .center-container .layui-nav-tree .layui-nav-item a {
        line-height: inherit;
        height: auto;
        background-color: inherit;
        color: inherit;
        text-decoration: none;
        border-color: var(--publicMainColor);
        box-shadow: 0 0 0px var(--publicMainColor);
    }</style>
<body class='bodyClass'>
<div id="app">
    <el-dialog :modal-append-to-body="false" :visible.sync="showContentModal" title="弹出内容">
        <div class="content" style="word-break: break-all;" v-html="showContent">
        </div>
        <div class="dialog-footer" slot="footer">
            <el-button @click="showContentModal = false">关 闭</el-button>
        </div>
    </el-dialog>
    <!-- 标题 -->
    <div :style='{"padding":"10px","boxShadow":"0 0 2px rgba(160, 67, 26, 1)","margin":"10px auto","borderColor":"rgba(0,0,0,.3)","color":"rgba(255, 255, 255, 1)","borderRadius":"4px","borderWidth":"0","fontSize":"20px","borderStyle":"solid","height":"auto"}'
         class="index-title sub_backgroundColor">
        <span>USER / ORDER</span><span>我的字典表</span>
    </div>


    <!-- 标题 -->
    <div class="center-container">
        <!-- 个人中心菜单 config.js-->
        <div :style='{"backgroundColor":"#fff","padding":"0","boxShadow":"0px 0px 1px rgba(181, 181, 181, 1)","margin":"0","borderColor":"rgba(191, 191, 191, 1)","backgroundColor":"rgba(255, 255, 255, 1)","borderRadius":"0","borderWidth":"0 0 1px 0","width":"20%","borderStyle":"solid"}'
             class="left-container">
            <ul class="layui-nav layui-nav-tree">
                <li :class="item.url=='../dictionary/list.html'?'layui-this':''" class="layui-nav-item" v-bind:key="index"
                    v-for="(item,index) in centerMenu">
                    <a :href="'javascript:jump(\''+item.url+'\')'">{{item.name}}</a>
                </li>
            </ul>
        </div>        <!-- 个人中心菜单 -->
        <div :style='{"padding":"20px","boxShadow":"0px rgba(255,0,0,.8)","margin":"0","backgroundColor":"#fff","borderRadius":"0","borderWidth":"1px","borderStyle":"solid","width":"80%"}' class="right-container sub_borderColor"
             style="overflow: auto">
            <div style="display: flex;height: 60px;align-items: center;margin-left: 15px;justify-content: space-between">
                <!--                <button @click="jump('../dictionary/add.html')" class="layui-btn layui-btn-lg btn-theme sub_backgroundColor" :style='{"padding":"0 15px","boxShadow":"0 0 8px rgba(0,0,0,0)","margin":"0 0 0 10px","borderColor":"#409EFF","color":"#333","borderRadius":"4px","borderWidth":"0","width":"auto","fontSize":"14px","borderStyle":"solid","height":"40px"}'>
                                    <i v-if="true" class="layui-icon">&#xe654;</i> 添加字典表信息
                                </button>-->
            </div>
            <table class="layui-table" lay-skin="nob">
                <thead>
                <tr>
                    <!-- 当前表 -->
                    <th>字段</th>
                    <th>字段名</th>
                    <th>编码</th>
                    <th>编码名字</th>
                    <th>备注</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-bind:key="index" v-for="(item,index) in dataList">
                    <td>{{item.dicCode}}</td>
                    <td>{{item.dicName}}</td>
                    <td>{{item.codeIndex}}</td>
                    <td>{{item.indexName}}</td>
                    <td>{{item.beizhu}}</td>
                    <td style="width: 100px;">
                        <!--
                            <button @click="jump('../dictionary/add.html?dictionaryId='+item.id)" type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm">
                                 修改
                            </button>
                        -->
                        <button @click="deleteData(item)" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm"
                                type="button">
                            <i class="layui-icon">&#xe640;</i> 删除
                        </button>
                        <button @click="wuyong(item.id)" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm" type="button"
                                v-if="item.dictionaryTypes==1 && false">
                            无用按钮
                        </button>
                    </td>
                </tr>
                </tbody>
            </table>
            <div :style="{textAlign:'center'}" class="pager" id="pager"></div>
        </div>
    </div>
</div>

<script charset="utf-8" src="../../xznstatic/js/bootstrap.min.js" type="text/javascript"></script>
<script charset="utf-8" src="../../xznstatic/js/echarts.min.js" type="text/javascript"></script>
<script src="../../layui/layui.js"></script>
<script src="../../js/vue.js"></script>
<!-- 引入element组件库 -->
<script src="../../xznstatic/js/element.min.js"></script>
<!-- 引入element样式 -->
<link href="../../xznstatic/css/element.min.css" rel="stylesheet">
<script src="../../js/config.js"></script>
<script src="../../modules/config.js"></script>
<script src="../../js/utils.js"></script>

<script type="text/javascript">
    Vue.prototype.myFilters = function (msg) {
        if (msg == null || msg == "") {
            return "";
        } else if (msg.length > 20) {
            msg.replace(/\n/g, "<br>");
            return msg.substring(0, 30) + "......";
        } else {
            return msg.replace(/\n/g, "<br>");
        }
    };
    var vue = new Vue({
        el: '#app',
        data: {
            userId: localStorage.getItem("userid"),//当前登录人的id
            sessionTable: localStorage.getItem("userTable"),//登录账户所在表名
            role: localStorage.getItem("role"),//权限
            //小菜单
            centerMenu: centerMenu,
            //项目路径
            baseUrl: "",
            //弹出内容模态框
            showContentModal: false,
            showContent: "",

            //查询条件
            searchForm: {
                page: 1
                , limit: 8
                , sort: "id"//字段
                , order: "desc"//asc desc
                , yonghuId: localStorage.getItem('userid')//只能查询自己
                , dicCode: ""
                , dicName: ""
                , indexName: ""
                , beizhu: ""
            },

            dataList: [],
        },
        filters: {
            subString: function (val) {
                if (val) {
                    val = val.replace(/<[^<>]+>/g, '').replace(/undefined/g, '');
                    if (val.length > 60) {
                        val = val.substring(0, 60);
                        val += '...';
                    }
                    return val;
                }
                return '';
            }
        },
        computed: {},
        methods: {
            isAuth(tablename, button) {
                return isFrontAuth(tablename, button);
            },
            jump(url) {
                jump(url);
            },
            jumpCheck(url, check1, check2) {
                if (check1 == "2" || check1 == 2) {//级联表的逻辑删除字段[1:未删除 2:已删除]
                    layui.layer.msg("已经被删除", {
                        time: 2000,
                        icon: 2
                    });
                    return false;
                }
                if (check2 == "2" || check2 == 2) {//是否下架[1:上架 2:下架]
                    layui.layer.msg("已经下架", {
                        time: 2000,
                        icon: 2
                    });
                    return false;
                }
                this.jump(url);
            },
            showContentFunction(content) {
                this.showContentModal = true;
                this.showContent = content.replaceAll("src=\"upload/", "src=\"" + this.baseUrl + "upload/");
            },
            wuyong(id) {
                var mymessage = confirm("确定要    吗？");
                if (!mymessage) {
                    return false;
                }
                layui.http.requestJson(`dictionary/update`, 'post', {
                    id: id,
//                    dictionaryTypes:1,
                }, function (res) {
                    if (res.code == 0) {
                        layui.layer.msg('操作成功', {time: 2000, icon: 6}, function () {
                            window.location.reload();
                        });
                    } else {
                        layui.layer.msg(res.msg, {time: 5000, icon: 5});
                    }
                });
            },
            deleteData(data) {
                var mymessage = confirm("确定要删除这条数据吗？");
                if (!mymessage) {
                    return false;
                }
                // 删除信息
                layui.http.requestJson(`dictionary/delete`, 'post', [data.id], (res) => {
                    if (res.code == 0) {
                        layer.msg('删除成功', {
                            time: 2000,
                            icon: 6
                        });
                        window.location.reload();
                    } else {
                        layer.msg(res.msg, {
                            time: 2000,
                            icon: 2
                        });
                    }
                });
            },

        }
    });

    layui.use(['layer', 'element', 'carousel', 'laypage', 'http', 'jquery', 'laydate', 'tinymce'], function () {
        var layer = layui.layer;
        var element = layui.element;
        var carousel = layui.carousel;
        var laypage = layui.laypage;
        var http = layui.http;
        var laydate = layui.laydate;
        var tinymce = layui.tinymce;
        window.jQuery = window.$ = jquery = layui.jquery;
        vue.baseUrl = http.baseurl

        localStorage.setItem("goUtl", "./pages/dictionary/list2.html")

        // var id = http.getParam('id');


        // 分页列表
        pageList();

        // 搜索按钮
        jquery('#btn-search').click(function (e) {
            pageList();
        });

        function pageList() {
            // 获取列表数据
            http.request('dictionary/list', 'get', vue.searchForm, function (res) {
                vue.dataList = res.data.list;
                // 分页
                laypage.render({
                    elem: 'pager',
                    count: res.data.total,
                    limit: vue.searchForm.limit,
                    groups: 3,
                    layout: ["prev", "page", "next"],
                    jump: function (obj, first) {
                        vue.searchForm.page = obj.curr;//翻页
                        //首次不执行
                        if (!first) {
                            http.request('dictionary/list', 'get', vue.searchForm, function (res1) {
                                vue.dataList = res1.data.list;
                            })
                        }
                    }
                });
            });
        }
    });

    window.xznSlide = function () {
        jQuery(".banner").slide({mainCell: ".bd ul", autoPlay: true, interTime: 5000});
        jQuery("#ifocus").slide({
            titCell: "#ifocus_btn li",
            mainCell: "#ifocus_piclist ul",
            effect: "leftLoop",
            delayTime: 200,
            autoPlay: true,
            triggerTime: 0
        });
        jQuery("#ifocus").slide({titCell: "#ifocus_btn li", mainCell: "#ifocus_tx ul", delayTime: 0, autoPlay: true});
        jQuery(".product_list").slide({
            mainCell: ".bd ul",
            autoPage: true,
            effect: "leftLoop",
            autoPlay: true,
            vis: 5,
            trigger: "click",
            interTime: 4000
        });
    };
</script>
</body>
</html>
